<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
	<base th:href="@{/}">
	<meta charset="utf-8">
	<title>新增</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/icon.css">
	<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
	<script type="text/javascript" src="static/layui/layui.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/jquery.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="static/js/common/reportTemplet.js"></script>
	<style type="text/css">
		.layui-form-label {
			white-space: nowrap;
			width: 120px;
			color: gray;
		}
	</style>
</head>
<body class="layui-fluid" th:fragment="body">
	<div class="layui-row">
		<div class="layui-col-md12">
			<form class="easyui-form" id="form" action="" autocomplete="off" style="padding-top: 1px;" data-options="novalidate:true">
			</form>
		</div>
	</div>
	<script type="text/javascript" th:inline="javascript">
		var obj = [[${obj}]]
		var html = '';
		for(var i in obj){
			switch (obj[i].type){
				case 'textbox':
					html=html+'<div class="layui-form-item" style="margin-top: 20px;">'
						+'<div class="layui-inline">'
							+'<label class="layui-form-label">'+obj[i].data.fieldExplain+'</label>'
							+'<div class="layui-input-inline">'
								+'<input id="'+obj[i].data.entityField+'" name="'+obj[i].data.entityField+'" class="easyui-textbox"'
								+(obj[i].data.required==true?"data-options=\"required:true,prompt:'请输入',missingMessage:'不能为空'\"":"")
								+'>'
							+'</div>'
						+'</div>'
					+'</div>'
					break;
				case 'numberbox':
					html=html+'<div class="layui-form-item" style="margin-top: 20px;">'
						+'<div class="layui-inline">'
							+'<label class="layui-form-label">'+obj[i].data.fieldExplain+'</label>'
							+'<div class="layui-input-inline">'
								+'<input name="'+obj[i].data.entityField+'" class="easyui-numberbox"'
								+(obj[i].data.required==true?"data-options=\"required:true,prompt:'请输入',missingMessage:'不能为空',precision:"+obj[i].data.numericScal+"\"":"data-options=\"precision:"+obj[i].data.numericScal+"\"")
								+'>'
							+'</div>'
						+'</div>'
					+'</div>'
					break;
				case 'combobox':
					html=html+'<div class="layui-form-item" style="margin-top: 20px;">'
						+'<div class="layui-inline">'
							+'<label class="layui-form-label">'+obj[i].data.fieldExplain+'</label>'
							+'<div class="layui-input-inline">'
								+'<input name="'+obj[i].data.entityField+'" class="easyui-combobox"'
								+"data-options=\"prompt:'请输入',missingMessage:'不能为空',prompt:'请选择',valueField: 'label',textField: 'value',data:[";
									var oppion = '';
									for(var j in obj[i].list){
										oppion=oppion+"{label: '"+obj[i].list[j].label+"',value: '"+obj[i].list[j].value+"'},";
									}
									oppion = oppion.substr(0, oppion.length-1);
									oppion=oppion+"]";
						html=html+oppion+(obj[i].data.required==true?",required:true":"")+"\">"
							+'</div>'
						+'</div>'
					+'</div>'
					break;
				case 'datebox':
					html=html+'<div class="layui-form-item" style="margin-top: 20px;">'
						+'<div class="layui-inline">'
							+'<label class="layui-form-label">'+obj[i].data.fieldExplain+'</label>'
							+'<div class="layui-input-inline">'
								+'<input name="'+obj[i].data.entityField+'" class="easyui-datebox"'
								+(obj[i].data.required==true?"data-options=\"onHidePanel : function() {" +
									"	var split = $(this).datebox('getValue').split('-');" +
									"	if(split.length != 3){" +
									"	$(this).datebox('setValue','');" +
									"	alert('预计成交时间格式为yyyy-MM-dd,请选择或者输入正确的格式');" +
									"}" +
									"},required:true,prompt:'请选择日期',missingMessage:'不能为空'\"":"")
								+'>'
							+'</div>'
						+'</div>'
					+'</div>'
					break;
				case 'datetimebox':
					html=html+'<div class="layui-form-item" style="margin-top: 20px;">'
							+'<div class="layui-inline">'
							+'<label class="layui-form-label">'+obj[i].data.fieldExplain+'</label>'
							+'<div class="layui-input-inline">'
							+'<input id="'+obj[i].data.entityField+'" name="'+obj[i].data.entityField+'" class="easyui-datetimebox"'
							+(obj[i].data.required==true?"data-options=\"onHidePanel : function() {" +
									"	var split = $(this).datetimebox('getValue').split('-');" +
									"	if(split.length != 3){" +
									"	$(this).datetimebox('setValue','');" +
									"	alert('预计成交时间格式为yyyy-MM-dd,请选择或者输入正确的格式');" +
									"}" +
									"},required:true,prompt:'请选择日期',missingMessage:'不能为空'\"":"")
							+'>'
							+'</div>'
							+'</div>'
							+'</div>'
					break;
			}
		}
		$("#form").html(html);
		function getFormDataAndValidate(){
			var flag = $("#form").form('enableValidation').form('validate');
			if(!flag){
				return [false,{}];
			}
			var data = $('#form').serializeArray();
			var obj = new Object();
			$.each(data, function(index, e){
				obj[e.name] = e.value;
			})
			return [true,obj];
		}
	</script>
</body>
</html>